package com.wx.mall.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wx.mall.sys.entity.MessageRemind;
import com.wx.mall.sys.mapper.MessageRemindMapper;
import com.wx.mall.sys.service.IMessageRemindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lixuqiang
 * @since 2020-03-18
 */
@Service
public class MessageRemindServiceImpl extends ServiceImpl<MessageRemindMapper, MessageRemind> implements IMessageRemindService {

    @Autowired
    private MessageRemindMapper messageRemindMapper;

    @Override
    public List<MessageRemind> find(MessageRemind messageRemind) {
        return messageRemindMapper.selectList(new QueryWrapper<MessageRemind>().setEntity(messageRemind));
    }

    @Override
    public MessageRemind get(String id) {
        return messageRemindMapper.selectById(id);
    }

    @Override
    public void save2(MessageRemind messageRemind) {
        messageRemind.setIsSend("0");
        messageRemind.setAddTime(new Date());
        messageRemind.setMessageClassification("电子邮件");
        messageRemindMapper.insert(messageRemind);
        messageRemind.setMessageClassification("站内消息");
        messageRemindMapper.insert(messageRemind);
        messageRemind.setMessageClassification("手机短信");
        messageRemindMapper.insert(messageRemind);
        messageRemind.setMessageClassification("APP消息推送");
        messageRemindMapper.insert(messageRemind);
    }

    @Override
    public void update(MessageRemind messageRemind) {
        messageRemind.setUpdateTime(new Date());
        messageRemindMapper.updateById(messageRemind);
    }
}
